package com.cobra.mapreduce.writableComparable;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class FlowDriver {
    public static void main(String[] args) throws Exception {
        //1.获取job
        Configuration configuration = new Configuration();
        Job job = Job.getInstance();

        //2.获取jar
        job.setJarByClass(FlowDriver.class);

        //3. 关联mapper和reducer
        job.setReducerClass(FlowReducer.class);
        job.setMapperClass(FlowMapper.class);
        //4.设置mapper的输出key和value类型
        job.setMapOutputKeyClass(FlowBean.class);
        job.setMapOutputValueClass(Text.class);
        // 5.设置最终数据的key和value类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);
        //6.设置输入和输出的路径
        FileInputFormat.setInputPaths(job, new Path("src/main/resources/phone.txt"));
        FileOutputFormat.setOutputPath(job, new Path("src/main/resources/output/writableComparable"));
        //7.提交job
        boolean b = job.waitForCompletion(true);
        System.exit(b ? 0 : 1);
    }
}
